-
Notifications
You must be signed in to change notification settings - Fork 248
feat: DA hints in p2p #2891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: DA hints in p2p #2891
Conversation
|
Claude finished @alpe's task in 1m 51s —— View job Code Review: DA Hints in P2PI've completed a comprehensive code review of this PR. Here are my findings organized by category: 1. Code Quality & Architecture✅ StrengthsClean Architecture: The DA hints implementation follows good separation of concerns:
Migration Strategy: The backward compatibility approach is well-designed:
|
|
The latest Buf updates on your PR. Results from workflow CI / buf-check (pull_request).
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2891 +/- ##
==========================================
+ Coverage 55.96% 56.13% +0.17%
==========================================
Files 117 118 +1
Lines 11844 12066 +222
==========================================
+ Hits 6628 6773 +145
- Misses 4486 4548 +62
- Partials 730 745 +15
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| cache.SetHeaderDAIncluded(headerHash.String(), res.Height, header.Height()) | ||
| hashes[i] = headerHash | ||
| } | ||
| if err := s.headerDAHintAppender.AppendDAHint(ctx, res.Height, hashes...); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where the DA height is passed to the sync service to update the p2p store
block/internal/syncing/syncer.go
Outdated
| Msg("P2P event with DA height hint, triggering targeted DA retrieval") | ||
|
|
||
| // Trigger targeted DA retrieval in background via worker pool | ||
| s.asyncDARetriever.RequestRetrieval(daHeightHint) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where the "fetch from DA" is triggered for the current block event height
pkg/sync/da_hint_container.go
Outdated
| type SignedHeaderWithDAHint = DAHeightHintContainer[*types.SignedHeader] | ||
| type DataWithDAHint = DAHeightHintContainer[*types.Data] | ||
|
|
||
| type DAHeightHintContainer[H header.Header[H]] struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a data container to persist the DA hint together with the block header or data.
types.SignedHeader and types.Data are used all over the place so I did not modify them but added introduced this type for the p2p store and transfer only.
It may make sense to do make this a Proto type. WDYT?
pkg/sync/sync_service.go
Outdated
| return nil | ||
| } | ||
|
|
||
| func (s *SyncService[V]) AppendDAHint(ctx context.Context, daHeight uint64, hashes ...types.Hash) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stores the DA height hints
|
if da hint is not in the proto how do other nodes get knowledge of the hint? also how would an existing network handle using this feature? its breaking so is it safe to upgrade? |
julienrbrt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! It really makes sense.
I share the same concern as @tac0turtle however about the upgrade strategy given it is p2p breaking.
The sync_service wraps the header/data payload in a
It is a breaking change. Instead of signed header or data types, the p2p network exchanges DAHeightHintContainer. This would be incompatible. Also the existing p2p stores would need migration to work. |
|
Could we broadcast both until every networks are updated? Then for final we can basically discard the previous one. |
|
fyi: This PR is missing a migration strategy for the p2p store ( and ideally network) |
* main: refactor(sequencers): persist prepended batch (#2907) feat(evm): add force inclusion command (#2888) feat: DA client, remove interface part 1: copy subset of types needed for the client using blob rpc. (#2905) feat: forced inclusion (#2797) fix: fix and cleanup metrics (sequencers + block) (#2904) build(deps): Bump mdast-util-to-hast from 13.2.0 to 13.2.1 in /docs in the npm_and_yarn group across 1 directory (#2900) refactor(block): centralize timeout in client (#2903) build(deps): Bump the all-go group across 2 directories with 3 updates (#2898) chore: bump default timeout (#2902) fix: revert default db (#2897) refactor: remove obsolete // +build tag (#2899) fix:da visualiser namespace (#2895)
* main: chore: execute goimports to format the code (#2924) refactor(block)!: remove GetLastState from components (#2923) feat(syncing): add grace period for missing force txs inclusion (#2915) chore: minor improvement for docs (#2918) feat: DA Client remove interface part 2, add client for celestia blob api (#2909) chore: update rust deps (#2917) feat(sequencers/based): add based batch time (#2911) build(deps): Bump golangci/golangci-lint-action from 9.1.0 to 9.2.0 (#2914) refactor(sequencers): implement batch position persistance (#2908)
<!-- Please read and fill out this form before submitting your PR. Please make sure you have reviewed our contributors guide before submitting your first PR. NOTE: PR titles should follow semantic commits: https://www.conventionalcommits.org/en/v1.0.0/ --> ## Overview Temporary fix until #2891. After #2891 the verification for p2p blocks will be done in the background. ref: #2906 <!-- Please provide an explanation of the PR, including the appropriate context, background, goal, and rationale. If there is an issue with this information, please provide a tl;dr and link the issue. Ex: Closes #<issue number> -->
|
I have added 2 new types for the p2p store that are binary compatible to the types.Data and SignedHeader. With this, we should be able to roll this out without breaking the in-flight p2p data and store. |
|
This is complete, but testing demonstrated DAHint are only populated when a node catchup from p2p and isn't synced until the head. If it is, the broadcasted message by the executor does not contain DA hint, as they are populated at DA inclusion (so later in the flow). This means they are only populated when syncing later. Looking at the issue, it looks like it is by design, but I'll document this behavior. Restarting a node, that catches up: $ curl http://localhost:7331/evnode.v1.StoreService/GetBlock --request POST --header 'Content-Type: application/json' --data '{
"height": 2876
}' | jq .
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 793 100 773 100 20 149k 3949 --:--:-- --:--:-- --:--:-- 154k
{
"block": {
"header": {
"header": {
"version": {},
"height": "2876",
"time": "1770111427619628631",
"lastHeaderHash": "9fihO5DYcLnxJ9UN0z4CYI5xC1twvoD3pXSQxPhPvDc=",
"dataHash": "bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"appHash": "Gf1RHYxYQQBBTpfpd8b5Fm2xBwaSsTS80LHTqrP+4uc=",
"proposerAddress": "8WmB7fiy1LKpjeJ9MLNoVELXfTXMZWBRgs2PMQUsmWo=",
"chainId": "1234"
},
"signature": "R822NZltoXRzyZWa2nzol0fMAXnJ7NrmH5JQa+FPe0XcyUcdyZYpPj8SpN+GEujS1NXb5aIXQyvAJ8GQnIubDw==",
"signer": {
"address": "8WmB7fiy1LKpjeJ9MLNoVELXfTXMZWBRgs2PMQUsmWo=",
"pubKey": "CAESINjAdIx+T8t6c4mGC3U/olPOnej/OzQZb3caPfvflcJU"
}
},
"data": {
"metadata": {
"chainId": "1234",
"height": "2876",
"time": "1770111427619628631",
"lastDataHash": "EsZtV2Sum7VkXgiVg6mr3ZlsmYTgWrGJSJfrgjMfHII="
}
}
},
"headerDaHeight": "198",
"dataDaHeight": "198"
}Once caught up: $ curl http://localhost:7331/evnode.v1.StoreService/GetBlock --request POST --header 'Content-Type: application/json' --data '{
"height": 2961
}' | jq .
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 749 100 729 100 20 172k 4849 --:--:-- --:--:-- --:--:-- 182k
{
"block": {
"header": {
"header": {
"version": {},
"height": "2961",
"time": "1770111471334149438",
"lastHeaderHash": "oiqDpIWHOk64ro75pffd1BU1zr9h1awn8zwuCnW+RqQ=",
"dataHash": "bjQLnP+zepicpUTmu3gKLHiQHT+zNzh2hRGjBhevoB0=",
"appHash": "Gf1RHYxYQQBBTpfpd8b5Fm2xBwaSsTS80LHTqrP+4uc=",
"proposerAddress": "8WmB7fiy1LKpjeJ9MLNoVELXfTXMZWBRgs2PMQUsmWo=",
"chainId": "1234"
},
"signature": "I++4UxCwkhGn7T5wM+sxp5rUuDg+qZkTtwjGwBXAU68N2/8MTtMPNeWw23lFUInEH+YFY57NjVpfAABZYAAJCQ==",
"signer": {
"address": "8WmB7fiy1LKpjeJ9MLNoVELXfTXMZWBRgs2PMQUsmWo=",
"pubKey": "CAESINjAdIx+T8t6c4mGC3U/olPOnej/OzQZb3caPfvflcJU"
}
},
"data": {
"metadata": {
"chainId": "1234",
"height": "2961",
"time": "1770111471334149438",
"lastDataHash": "GSB1zy9zxSjanCflzmr3m07IfyiDuIVDVLRCPNvRiQ4="
}
}
}
} |
| g.Go(func() error { return e.dataBroadcaster.WriteToStoreAndBroadcast(broadcastCtx, data) }) | ||
| g, broadcastCtx := errgroup.WithContext(e.ctx) | ||
| g.Go(func() error { | ||
| return e.headerBroadcaster.WriteToStoreAndBroadcast(broadcastCtx, &types.P2PSignedHeader{SignedHeader: header}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ref: #2891 (comment)
|
Overview
Resolves #2609
The basic idea is to store an additional DAHightHint field within the p2p store.
As SignedHeader and Data are used in other places, too. I added an an
DAHeightHintContainertype to wrap the tuple for the store only.The DAHeight Hint is added by the da_submitter and read in the syncer to fetch the missing DA header/data for the most recent block as required.
Please note: this is a breaking change to the p2p network
and store